package com.handpay.nocardpay.baselibrary.download.widget;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Messenger;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

import com.handpay.nocardpay.baselibrary.R;
import com.handpay.nocardpay.baselibrary.download.view.activity.DownloadApkActivity;
import com.handpay.nocardpay.baselibrary.logutils.HPLog;

import org.json.JSONException;
import org.json.JSONObject;


/**
 * @author feicien (ithcheng@gmail.com)
 * @since 2016-07-05 19:21
 */
public class CheckUpdateTask {
    public static final int TYPE_NOTIFICATION = 2;
    public static final int TYPE_DIALOG = 1;
    private ProgressDialog dialog;
    private Context mContext;
    private int mType;
    private boolean mShowProgressDialog;
    //    private static final String url = Constants.UPDATE_URL;
    private Handler mHandler;

    public CheckUpdateTask(Context context, int type, boolean showProgressDialog, Handler handler) {

        this.mContext = context;
        this.mType = type;
        this.mShowProgressDialog = showProgressDialog;
        this.mHandler = handler;

    }

    public void startDownload(String apkUrl) {
        showNotification(mContext, apkUrl);
    }

    /**
     * Show Notification
     */
    private void showNotification(Context context, String apkUrl) {
        Intent myIntent = new Intent(context, DownloadService.class);
        myIntent.putExtra(DownloadService.APK_DOWNLOAD_URL, apkUrl);
        myIntent.putExtra(DownloadService.KEY_MESSAGE, new Messenger(mHandler));
        context.startService(myIntent);
    }


}
